#coding:utf-8
import time as py_time

import settings

class Dm(object):
    def __init__(self, text, sender, position, font, color, size, time, id = None):
        self._text = text
        self._sender = sender
        self._position = position
        self._font = font
        self._color = int(color)
        self._size = int(size)
        self._time = time
        self._id = None

    def dict(self):
        return {
            "id" : self._id,
            "text" : self._text,
            "sender" : self._sender,
            "position" : self._position,
            "font" : self._font,
            "color" : self._color,
            "size" : self._size,
            "time" : self._time,
        }

    @property
    def id_(self):
        return self._id

    @property
    def text(self):
        return self._text

    @property
    def sender(self):
        return self._sender

    @property
    def position(self):
        return self._position
    
    @property
    def font(self):
        return self._font

    @property
    def color(self):
        return self._color

    @property
    def size(self):
        return self._size

    @property
    def time(self):
        return self._time

    def save(self):
        raise NotImplementedError


class Room(object):
    def __init__(self, name, password = None):
        self._name = name
        self._password = password
        self._config = None

    @property
    def name(self):
        return self._name

    @property
    def password(self):
        return self._password

    @password.setter
    def password(self, value):
        m = hashlib.md5()
        m.update(value.encode('utf-8'))
        self._password = m.hexdigest()

    @property
    def config(self):
        return self._config

    def save(self):
        raise NotImplementedError

    def dict(self):
        return {
            "name" : self._name,
            "password" : self._password,
            "config" : self._config
        }


